<template>
	<div>
		<p>子组件2</p>
		{{val}}
	</div>

</template>

<script>
	// import Bus from '@/utils/bus.js'
	export default {
		data() {
			return {
				val: ''
			}
		},
		created() {
			this.$bus.$on('transData', this.getVal) //监听transData
		},
		beforeDestroy() {//收尾操作，销毁
			this.$bus.$off('transData') //卸载	transData，否则会造成内存泄露
		},
		methods: {
			getVal(val) {
				this.val = val
			}
		}
	}
</script>

<style scoped>
</style>